package com.ytjj.qmyx.mall.service.thirdpay;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.Jeepay;
import com.jeequan.jeepay.JeepayClient;
import com.jeequan.jeepay.exception.JeepayException;
import com.jeequan.jeepay.model.PayOrderCreateReqModel;
import com.jeequan.jeepay.model.RefundOrderCreateReqModel;
import com.jeequan.jeepay.request.PayOrderCreateRequest;
import com.jeequan.jeepay.request.RefundOrderCreateRequest;
import com.jeequan.jeepay.response.PayOrderCreateResponse;
import com.jeequan.jeepay.response.RefundOrderCreateResponse;
import com.ytjj.common.exception.GlobalExceptionHandler;
import com.ytjj.common.service.RedisService;
import com.ytjj.common.utils.DateTimeUtil;
import com.ytjj.common.utils.HttpClientUtil;
import com.ytjj.common.utils.IPUtil;
import com.ytjj.common.utils.TokenUtil;
import com.ytjj.common.utils.feishu.FeiShuUtil;
import com.ytjj.qmyx.mall.config.SupplyApiConfig;
import com.ytjj.qmyx.mall.constants.IsPayConstant;
import com.ytjj.qmyx.mall.enums.OrderPaySource;
import com.ytjj.qmyx.mall.enums.OrderPayTypeEnums;
import com.ytjj.qmyx.mall.enums.OrderStatusEnums;
import com.ytjj.qmyx.mall.enums.PayPayTypeEnums;
import com.ytjj.qmyx.mall.mapper.*;
import com.ytjj.qmyx.mall.model.*;
import com.ytjj.qmyx.mall.model.dto.WxPayDto;
import com.ytjj.qmyx.mall.model.request.UpdateOrderStatusRequest;
import com.ytjj.qmyx.mall.service.OrdersService;
import com.ytjj.qmyx.mall.service.ProductService;
import com.ytjj.qmyx.mall.service.WxService;
import com.ytjj.qmyx.mall.service.thirdpay.entity.WysOrderNotify;
import com.ytjj.qmyx.mall.service.thirdpay.entity.WysReturnOrderNotify;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 智收营相关业务
 */
@Service("APP-ZSY")
@Slf4j
public class ZsxService implements WxService<WxPayDto> {

    @Value("${zsyNotifyUrl:}")
    private String zsyNotifyUrl;

    @Value("${zsyReturnUrl:}")
    private String zsyReturnUrlNotifyUrl;

    @Resource
    private OrdersDao ordersDao;

    @Resource
    private OrdersPayMapper ordersPayMapper;
    @Resource
    private OrdersMapper ordersMapper;
    @Resource
    private OrdersInfoMapper ordersInfoMapper;

    @Resource
    private RedisService redisService;
    @Resource
    private ProductService productService;

    @Resource
    private OrdersService ordersService;

    @Resource
    private ReturnGoodsDao returnGoodsDao;
    @Resource
    private SupplyApiConfig supplyApiConfig;

    private static final String apiKeyOld ="TTKsWAjlqospiQtM9gDyGQ0ooap0Fw3ejiutv4xp9ykyYl6JQexQU03YGXeaq2ohydhB2qL8cCPexjXyZ7yorlnYm1y3Cv4AA4vOJhWNYkq5XdIMt4IelZ9q8K7RJshH";
    private static final String mchNoOld ="Z1736236759";
    private static final String appIdOld ="677cded8e4b0c6b9b39949e0";

    @PostConstruct
    public void init() {

        Jeepay.setApiBase("https://pay.zhishouying.com");
//        Jeepay.apiKey = "TTKsWAjlqospiQtM9gDyGQ0ooap0Fw3ejiutv4xp9ykyYl6JQexQU03YGXeaq2ohydhB2qL8cCPexjXyZ7yorlnYm1y3Cv4AA4vOJhWNYkq5XdIMt4IelZ9q8K7RJshH";
//        Jeepay.mchNo = "Z1736236759";
//        Jeepay.appId = "677cded8e4b0c6b9b39949e0";
        Jeepay.apiKey = "QTl2uov5Ty7LBy9vmNX3eNDh1iLPi2nDa3l1yto8hibzADGHfuPk6m2fxG5ZH5gAF6ATDpTOcQAGTDTZ3d8dODfSw59SOtjDSBZPgxj4URl5z1EZf8NGNs2CZfcFurKh";
        Jeepay.mchNo = "Z1739360563";
        Jeepay.appId = "67ac8933e4b0c8aa9516659a";
    }

    @Override
    public Map<String, String> doUnifiedOrder(WxPayDto wxAppPayDto) throws Exception {

        Map<String,String> param = new HashMap<>();

        String ip;
        try {
            ip = IPUtil.getIpAddress(TokenUtil.getRequest());
        } catch (Exception e) {
            log.error("ip获取报错:",e);
            ip = "0.0.0.0";
        }

        /*
            支持自己定义RequestOptions属性,更灵活
            RequestOptions options = RequestOptions.builder().setAppId("60deb8d6c6104c854e2346e4").setApiKey("11982212000912313").setUri("api/pay/unifiedOrder").setReadTimeout(100).build();
            PayOrderCreateRequest request = new PayOrderCreateRequest();
            request.setRequestOptions(options);
        */

        /*
            特殊支付方式：
            QR_CASHIER  ( 通过二维码跳转到收银台完成支付， 已集成获取用户ID的实现。  )
            ALI_QR 支付宝
            AUTO_BAR （自动分类条码支付）
        */

        // 支付接口文档：https://docs.jeequan.com/docs/jeepay/payment_api
        JeepayClient jeepayClient = JeepayClient.getInstance(Jeepay.appId, Jeepay.apiKey, Jeepay.getApiBase());
        // 支付方式
        String wayCode = wxAppPayDto.getWayCode();
        PayOrderCreateRequest request = new PayOrderCreateRequest();
        PayOrderCreateReqModel model = new PayOrderCreateReqModel();
        // 商户号
        model.setMchNo(Jeepay.mchNo);
        // 应用ID
        model.setAppId(jeepayClient.getAppId());
        // 商户订单号
        model.setMchOrderNo(wxAppPayDto.getResOrderNo());
        // 支付方式
        model.setWayCode(wayCode);
        // 金额，单位分
        model.setAmount(Long.parseLong(wxAppPayDto.getRealTotalMoney()));
        // 币种，目前只支持cny
        model.setCurrency("CNY");
        // 发起支付请求客户端的IP地址
        model.setClientIp(ip);
        // 商品标题
        model.setSubject(wxAppPayDto.getBody());
        // 商品描述
        model.setBody(wxAppPayDto.getBody());
        // 异步通知地址
        model.setNotifyUrl(zsyNotifyUrl);
        // 前端跳转地址
        model.setReturnUrl("");
        // 渠道扩展参数
        model.setChannelExtra(channelExtra(wayCode));
        // 商户扩展参数,回调时原样返回
        model.setExtParam("");

        request.setBizModel(model);
        try {
            PayOrderCreateResponse response = jeepayClient.execute(request);
            log.info("验签结果：{}", response.checkSign(Jeepay.apiKey));
            // 下单成功
            if(response.isSuccess(Jeepay.apiKey)) {
                String payOrderId = response.get().getPayOrderId();
                log.info("payOrderId：{}", payOrderId);
                log.info("mchOrderNo：{}", response.get().getMchOrderNo());
                log.info("getPayData：{}", response.get().getPayData());
                param.put("redirectUrl",response.get().getPayData());
            }else {
                log.error("下单失败：{}", wxAppPayDto.getResOrderNo());
                log.error("通道错误码：{}", response.get().getErrCode());
                log.error("通道错误信息：{}", response.get().getErrMsg());
                FeiShuUtil.sendMsgMxl(String.format("调取第三方支付失败,%s,%s,%s",wxAppPayDto.getResOrderNo(),response.get().getErrCode(),response.get().getErrMsg()));
            }
        } catch (Exception e) {
            log.error("智收营支付报错,{}",e);
            throw new RuntimeException(e);
        }
        return param;
    }

    String channelExtra(String wayCode) {
        if("WX_JSAPI".equals(wayCode)) {
            return wxJsapiExtra();
        }
        if("WX_BAR".equals(wayCode)) {
            return wxBarExtra();
        }
        if("ALI_BAR".equals(wayCode)) {
            return aliBarExtra();
        }
        if("YSF_BAR".equals(wayCode)) {
            return ysfBarExtra();
        }
        if("UPACP_BAR".equals(wayCode)) {
            return upacpBarExtra();
        }
        if("QR_CASHIER".equals(wayCode)) {
            return qrCashierExtra();
        }
        if("AUTO_BAR".equals(wayCode)) {
            return autoBarExtra();
        }
        if("PP_PC".equals(wayCode)) {
            return ppExtra();
        }
        if("SAND_H5".equals(wayCode)) {
            return sandH5Extra();
        }
        if ("ALI_QR".equals(wayCode)) {
            return aliQrExtract();
        }
        return "";
    }
    private String aliQrExtract(){
        JSONObject obj = new JSONObject();
        obj.put("payDataType", "codeUrl");
        return obj.toString();
    }

    private String wxJsapiExtra() {
        JSONObject obj = new JSONObject();
        obj.put("payDataType", "134756231107811344");
        return obj.toString();
    }

    private String wxBarExtra() {
        JSONObject obj = new JSONObject();
        obj.put("authCode", "134675721924600802");
        return obj.toString();
    }

    private String aliBarExtra() {
        JSONObject obj = new JSONObject();
        obj.put("authCode", "1180812820366966512");
        return obj.toString();
    }

    private String ysfBarExtra() {
        JSONObject obj = new JSONObject();
        obj.put("authCode", "6223194037624963090");
        return obj.toString();
    }

    private String upacpBarExtra() {
        JSONObject obj = new JSONObject();
        obj.put("authCode", "6227662446181058584");
        return obj.toString();
    }

    private String qrCashierExtra() {
        JSONObject obj = new JSONObject();
        //obj.put("payDataType", "codeImgUrl");
        obj.put("entryPageType", "lite");
        obj.put("entryLiteType", "wxh5");
        obj.put("payDataType", "payUrl");

        return obj.toString();
    }

    private String autoBarExtra() {
        JSONObject obj = new JSONObject();
        obj.put("authCode", "134753177301492386");
        return obj.toString();
    }

    private String ppExtra() {
        JSONObject obj = new JSONObject();
        obj.put("cancelUrl", "http://baidu.com");
        return obj.toString();
    }

    private String sandH5Extra() {
        JSONObject obj = new JSONObject();
        JSONObject payExtra = new JSONObject();
        // 聚合码
        obj.put("productCode", "02000001");
        obj.put("payExtra", "");
        obj.put("metaOption", "[{\"s\":\"Pc\",\"n\":\"支付\"}]");
        // 微信公众号
        /*obj.put("productCode", "02010002");
        payExtra = new JSONObject();
        payExtra.put("mer_app_id", "");
        payExtra.put("openid", "");
        obj.put("payExtra", payExtra.toString());
        obj.put("metaOption", "");
        // 微信小程序(云函数sdk)
        obj.put("productCode", "02010007");
        payExtra = new JSONObject();
        payExtra.put("wx_app_id", "");  // 移动应用Appid（微信开放平台获取，wx开头）
        payExtra.put("gh_ori_id", "");  // 小程序原始id（微信公众平台获取，gh_开头）
        payExtra.put("path_url", "");   // 拉起小程序页面的可带参路径，不填默认拉起小程序首页
        payExtra.put("miniProgramType", "0");   // 开发时根据小程序是开发版、体验版或正式版自行选择。正式版:0; 开发版:1; 体验版:2
        obj.put("payExtra", payExtra.toString());
        obj.put("metaOption", "");
        // 支付宝生活号
        obj.put("productCode", "02010002");
        payExtra = new JSONObject();
        payExtra.put("buyer_id", "");  // 支付宝生活号所需参数（支付宝H5建议不传）
        obj.put("payExtra", payExtra.toString());
        obj.put("metaOption", "");*/
        return obj.toString();

    }

    public void notifyZSY(WysOrderNotify wxPayNotify){
        updateOrderInfo(wxPayNotify);
    }

    public void updateOrderInfo(WysOrderNotify wxPayNotify){
        Integer status = wxPayNotify.getState();
        String orderNo = wxPayNotify.getMchOrderNo();

        OrdersPay pay = ordersDao.queryOrdersPayByResOrderNo(orderNo);
        pay.setResText(JSON.toJSONString(wxPayNotify));
        if (status.equals(2)){
            String serialNumber = wxPayNotify.getChannelOrderNo();
            Integer orderAmount = wxPayNotify.getAmount();

            if (StringUtils.isNotBlank(orderNo)){
                if (null == pay || (pay.getPayType().byteValue() == PayPayTypeEnums.SUCCEED.getType())) {
                    return;
                }
                // 更新支付订单信息
                if (orderAmount!=null) {
                    pay.setTotalFee(orderAmount);
                } else {
                    if (null != pay.getAmount()) {
                        BigDecimal big_total_fee = pay.getAmount().multiply(new BigDecimal(100));
                        pay.setTotalFee(big_total_fee.intValue());
                    }
                }
                pay.setPayTime(DateTimeUtil.getTime());
                pay.setPayType(PayPayTypeEnums.SUCCEED.getType());
                pay.setUpdateTime(new Date());
                pay.setTransactionId(serialNumber);
                ordersPayMapper.updateByPrimaryKeyWithBLOBs(pay);

                // 更新订单信息
                Orders orders = new Orders();
                orders.setPayType(OrderPayTypeEnums.online_pay.name());

                orders.setPaySource(OrderPaySource.alipay.name());

                orders.setIsPay(IsPayConstant.YES);
                orders.setOrderStatus(OrderStatusEnums.UNSHIPPED.getValue());
                orders.setPayTime(new Date());
                orders.setTradeNo(pay.getResOrderNo());
                orders.setAccount("智收银");
                OrdersExample example = new OrdersExample();
                example.createCriteria()
                        .andOrderNoEqualTo(pay.getOrderNo());
                ordersMapper.updateByExampleSelective(orders, example);
                // 获取订单信息
                Orders order = ordersDao.queryOrdersByOrderNo(pay.getOrderNo());

                // 获取订单明细
                OrdersInfoExample ordersInfoExample = new OrdersInfoExample();
                ordersInfoExample.createCriteria().andOrderIdEqualTo(order.getId());
                List<OrdersInfo> ordersInfoList = ordersInfoMapper.selectByExample(ordersInfoExample);
                ordersInfoList.stream()
                        .forEach(item -> {
                            String tokenUser = redisService.get(order.getH5Token());

                            // 修改订单详情状态
                            OrdersInfo ordersInfo = new OrdersInfo();
                            ordersInfo.setId(item.getId());
                            ordersInfo.setOrderinfoStatus(OrderStatusEnums.UNSHIPPED.getValue());
                            ordersInfoMapper.updateByPrimaryKeySelective(ordersInfo);
                            try {
                                // 商品 减库存 加销量 店家加销量
                                productService.sellAfter(item.getProductId(), item.getProductSpecId(), item.getProductSum(), item.getProductPrice(),
                                        item.getIsWalletPay(),tokenUser, item.getIsDirectbuy(), item.getActivityType(), item.getActivityMax(), order.getUserId());
                            } catch (Exception e) {
                                log.error(GlobalExceptionHandler.getExceptionToString(e));
                                log.error("减库存发生异常 订单id :{}", item.getId());
                            }

                        });
                //扣减库存
                try {
                    ordersService.subStock(order.getId());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        if (status.equals(3)){
            // 更新支付订单信息
            pay.setPayType(PayPayTypeEnums.FAIL.getType());
            pay.setUpdateTime(new Date());
            ordersPayMapper.updateByPrimaryKeyWithBLOBs(pay);
        }
    }

    @Override
    public Map<String, String> doUnifiedRechargeOrder(WxPayDto wxPayDto) throws Exception {
        return null;
    }

    @Override
    public Map<String, String> wxOrderQuery(String resOrderNo) throws Exception {
        return null;
    }

    @Override
    public Map<String, String> wxPhoneChargesQuery(String resOrderNo) throws Exception {
        return null;
    }

    @Override
    public Map refundOrders(String outTradeNo, String outRefundNo, Integer totalFee, Integer refundFee, String refundDesc) throws Exception {
        return null;
    }

    @Override
    public Map refundRecharge(String outTradeNo, String outRefundNo, Integer totalFee, Integer refundFee, String refundDesc) throws Exception {
        return null;
    }

    public int zsyRefund(String mchOrderNo,String refundNo,String amount,String payTime){
        String apikey = Jeepay.apiKey;
        JeepayClient jeepayClient = JeepayClient.getInstance(Jeepay.appId, Jeepay.apiKey, Jeepay.getApiBase());

        RefundOrderCreateRequest request = new RefundOrderCreateRequest();
        RefundOrderCreateReqModel model = new RefundOrderCreateReqModel();

        model.setMchNo(Jeepay.mchNo);                       // 商户号
        //之前的订单是另外一个商户号 切换之前的
        if (StringUtils.isNotBlank(payTime)){
            if (DateTimeUtil.compareTime2(payTime,"2025-02-13 09:30:28")){
                jeepayClient = JeepayClient.getInstance(appIdOld, apiKeyOld, Jeepay.getApiBase());
                model.setMchNo(mchNoOld);
                apikey = apiKeyOld;
            }
        }
        model.setAppId(jeepayClient.getAppId());            // 应用ID
        model.setMchOrderNo(mchOrderNo);                            // 商户支付单号(与支付订单号二者传一)
//        model.setPayOrderId("P1877676410599305217");      // 支付订单号(与商户支付单号二者传一)
        model.setMchRefundNo(refundNo);                // 商户退款单号
        model.setRefundAmount(Long.parseLong(amount));                          // 退款金额，单位分
        model.setCurrency("cny");                           // 币种，目前只支持cny
//        model.setClientIp("192.166.1.132");                 // 发起支付请求客户端的IP地址
        model.setRefundReason("平台退款");                    // 退款原因
        model.setNotifyUrl(zsyReturnUrlNotifyUrl);      // 异步通知地址
        model.setChannelExtra("");                          // 渠道扩展参数
        model.setExtParam("");                              // 商户扩展参数,回调时原样返回
        request.setBizModel(model);
        try {
            RefundOrderCreateResponse response = jeepayClient.execute(request);
            log.info("验签结果：{}", response.checkSign(apikey));
            // 判断退款发起是否成功（并不代表退款成功）
            if(response.isSuccess(apikey)) {
                String refundOrderId = response.get().getRefundOrderId();
                log.info("refundOrderId：{}", refundOrderId);
                log.info("mchRefundNo：{}", response.get().getMchRefundNo());
            }else {
                log.info("退款失败：refundOrderNo={}, msg={}", mchOrderNo, response.getMsg());
                log.info("通道错误码：{}", response.get().getErrCode());
                log.info("通道错误信息：{}", response.get().getErrMsg());
            }
        } catch (JeepayException e) {
            log.error(e.getMessage());
            return 0;
        }
        return 1;
    }

    public int zsyRefundCJ(String mchOrderNo,String refundNo,String amount,String payTime){
        String apikey = Jeepay.apiKey;
        JeepayClient jeepayClient = JeepayClient.getInstance(Jeepay.appId, Jeepay.apiKey, Jeepay.getApiBase());
        RefundOrderCreateRequest request = new RefundOrderCreateRequest();
        RefundOrderCreateReqModel model = new RefundOrderCreateReqModel();
        model.setMchNo(Jeepay.mchNo);                       // 商户号
        //之前的订单是另外一个商户号 切换之前的
        if (StringUtils.isNotBlank(payTime)){
            if (DateTimeUtil.compareTime2(payTime,"2025-02-13 09:30:28")){
                jeepayClient = JeepayClient.getInstance(appIdOld, apiKeyOld, Jeepay.getApiBase());
                model.setMchNo(mchNoOld);
                apikey = apiKeyOld;
            }
        }
        model.setAppId(jeepayClient.getAppId());            // 应用ID
        model.setMchOrderNo(mchOrderNo);                            // 商户支付单号(与支付订单号二者传一)
//        model.setPayOrderId("P1877676410599305217");      // 支付订单号(与商户支付单号二者传一)
        model.setMchRefundNo(refundNo);                // 商户退款单号
        model.setRefundAmount(Long.parseLong(amount));                          // 退款金额，单位分
        model.setCurrency("cny");                           // 币种，目前只支持cny
        model.setRefundReason("平台退款");                    // 退款原因
        model.setChannelExtra("");                          // 渠道扩展参数
        model.setExtParam("");                              // 商户扩展参数,回调时原样返回
        request.setBizModel(model);
        try {
            RefundOrderCreateResponse response = jeepayClient.execute(request);
            log.info("验签结果：{}", response.checkSign(apikey));
            // 判断退款发起是否成功（并不代表退款成功）
            if(response.isSuccess(apikey)) {
                String refundOrderId = response.get().getRefundOrderId();
                log.info("refundOrderId：{}", refundOrderId);
                log.info("mchRefundNo：{}", response.get().getMchRefundNo());
            }else {
                log.info("退款失败：refundOrderNo={}, msg={}", mchOrderNo, response.getMsg());
                log.info("通道错误码：{}", response.get().getErrCode());
                log.info("通道错误信息：{}", response.get().getErrMsg());
                return 0;
            }
        } catch (JeepayException e) {
            log.error(e.getMessage());
            return 0;
        }
        return 1;
    }

    public void notifyZsyRefund(WysReturnOrderNotify data){

        int status = data.getState();
        String mchRefundNo = data.getMchRefundNo();
        if (status ==2){
            try {
                Thread.sleep(1500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            //修改订单相关状态
            updateAdminOrderInfo(mchRefundNo);
            // 退款表状态更新
            ordersDao.updateOrderRefundStatusByRefundNo(2,mchRefundNo,JSON.toJSONString(data));
        }
        if (status==3){
            // 退款表状态更新
            ordersDao.updateOrderRefundStatusByRefundNo(3,mchRefundNo,JSON.toJSONString(data));
        }
    }

    public void updateAdminOrderInfo(String trade_no){
        Integer orderInfoId = ordersDao.findOrderInfoIdByRefundNo(trade_no);
        log.info("trade_no:{},orderInfoId:{}",trade_no,orderInfoId);
        if (orderInfoId!=null){
            ReturnGoods returnGoodsInfo = ordersDao.selectReturnGoodsByWaitBackAmount(orderInfoId);
            log.info("ReturnGoods:{}",JSON.toJSONString(returnGoodsInfo));
            if (returnGoodsInfo!=null){
                // 同步退货管理中的退货状态
                returnGoodsDao.returnGoodsSuccess(returnGoodsInfo.getId());
                //交易关闭原因
                String closeRemarks = getCloseRemarks(returnGoodsInfo);

                //退款成功主子订单为已关闭
                OrdersInfo ordersInfo = ordersInfoMapper.selectByPrimaryKey(returnGoodsInfo.getOrdersInfoId());
                ordersDao.updateStatusByOid(returnGoodsInfo.getOrdersInfoId(), "4", closeRemarks);
                ordersDao.updateOrderStatusById(ordersInfo.getOrderId(),"4",returnGoodsInfo.getServiceNo());

                // 原路返回页中订单详情状态改为已关闭
                ordersDao.modifiedReturnRegister(returnGoodsInfo.getOrdersInfoId());

                //更新供应链订单状态  销售端调用 （当销售端退款后，需要修改订单状态）
                UpdateOrderStatusRequest updateOrderStatusRequest = new UpdateOrderStatusRequest();
                updateOrderStatusRequest.setChildOrderNo(ordersInfo.getChildOrderNo());
                updateOrderStatusRequest.setShopId(supplyApiConfig.getShopId());
                updateOrderStatusRequest.setOrderStatus(4);
                String json = JSON.toJSONString(updateOrderStatusRequest);
                HttpClientUtil.doPostJson(supplyApiConfig.getUrl() + "/order/updateOrderStatus", json, supplyApiConfig.getHeadsMap());

                //更新供应链售后信息
                YxReturnGoods yxReturnGoodsRequest = new YxReturnGoods();
                yxReturnGoodsRequest.setServiceNo(returnGoodsInfo.getServiceNo());
                yxReturnGoodsRequest.setStatus(9);

                yxReturnGoodsRequest.setShopId(supplyApiConfig.getShopId());
                String json2 = JSON.toJSONString(yxReturnGoodsRequest);
                HttpClientUtil.doPostJson(supplyApiConfig.getUrl() + "/returnGoods/updateReturnGoods", json2, supplyApiConfig.getHeadsMap());
            }
        }
    }

    public String getCloseRemarks(ReturnGoods returnGoodsInfo) {
        String closeRemarks = "";
        if (returnGoodsInfo.getAfterType() == 1) {
            closeRemarks = "订单已申请退款";
        } else if (returnGoodsInfo.getAfterType() == 2) {
            closeRemarks = "订单已申请退货退款";
        } else if (returnGoodsInfo.getAfterType() == 3) {
            closeRemarks = "订单已申请仅退款";
        }
        return closeRemarks;
    }
}
